﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../Js/Jquery/core/jquery.core.js" type="text/javascript"></script>
    <script src="../Js/Jquery/core/jquery.core.extend.js" type="text/javascript"></script>
    <script src="../Js/Jquery/plugins/jquery.hotkeys.js" type="text/javascript"></script>
    <script type="text/javascript">

        function test() {
            var ret = "{ResponseOption:[";
            $.each($(".divAnswer"), function (index, item) {
                var question = $(item).attr('question');
                var type = parseInt($(item).attr('type'));
                // chỉ luu gia tri value cho cac cau SA,MA,Scale
                ret += "{";
                ret += $.string.Format("question:'{0}',", question);
                ret += $.string.Format("type:'{0}'", type);
                var ResponseValue = "";
                switch (type) {
                    case 0: //SA
                    case 2: //True/False
                    case 4: //Scale
                        $.each($($.string.Format('input:radio[question="{0}"]:checked', question)), function (index, item) {
                            console.log($(this));
                            ResponseValue += $(this).val() + ',';
                        });
                        if (ResponseValue.length > 0)
                            ResponseValue = ResponseValue.substr(0, ResponseValue.length - 1);
                        ret += $.string.Format(",ResponseValue:'{0}'", ResponseValue);
                        break;
                    case 1: //Checkbox        
                        console.log($.string.Format('input:checkbox[question="{0}"]:checked', question));
                        $.each($($.string.Format('input:checkbox[question="{0}"]:checked', question)), function (index, item) {
                            ResponseValue += $(this).val() + ',';
                        });
                        if (ResponseValue.length > 0)
                            ResponseValue = ResponseValue.substr(0, ResponseValue.length - 1);
                        ret += $.string.Format(",ResponseValue:'{0}'", ResponseValue);

                        break;
                }
                ret += "},";
            });

            if (ret != "{ResponseOption:[")
                ret = ret.substr(0, ret.length - 1);
            ret += "]}";
            $("#Result").html(ret);
        }

        $(function () {
            $("input:radio").bind("click", function () {
                if ($(this).attr('select') == undefined) {
                    $(this).attr('select', 1);
                    $(this).attr('checked', "checked");
                }
                else {
                    $(this).removeAttr("select")
                    $(this).removeAttr("checked")
                }


            });

            $("input").bind('keydown', 'Enter', function (evt) {
                console.log($(this));
              //  var type = parseInt($("#ddlQuestionType").val() + '');

                
                return false;
            })

        });
    </script>
</head>
<body>
<input type="text" class="optAnswers" />
    <div style="display: none;">
        <label>
            ID</label>
        <input type="text" id="txtID" data-field="ID" class="ui-widget-content ui-corner-all">
    </div>
    <div class="new-row">
        <label style="vertical-align: top">
            Mô tả</label>
        <textarea id="txtContent" data-field="Content" class="ui-widget-content ui-corner-all"
            rows="3"></textarea>
    </div>
    <div class="new-row">
        Câu số 1:<div class="Question">
            Ngồi buồn anh lại làm thơ Tặng em đôi nữa giấc mơ muộn màng</div>
    </div>
    <div class="new-row divAnswer" question="1" type="0">
        <div>
            <input type="radio" question="1" value="1">1</div>
        <div>
            <input type="radio" question="1" value="2">22</div>
        <div>
            <input type="radio" question="1" value="3">333</div>
        <div>
            <input type="radio" question="1" value="4">4444</div>
    </div>
    <div class="new-row">
        Câu số 2:<div class="Question">
            Nếu thương anh sống đơn côi Thì em hãy lại ghép đôi đi nào</div>
    </div>
    <div class="new-row divAnswer" question="2" type="1">
        <div>
            <input type="checkbox" question="2" value="47">1</div>
        <div>
            <input type="checkbox" question="2" value="48">2</div>
        <div>
            <input type="checkbox" question="2" value="49">3</div>
        <div>
            <input type="checkbox" question="2" value="50">4</div>
    </div>
    <div class="new-row" id="divNextQuestion">
        <label>
            Câu hỏi kế tiếp</label>
        <select id="cboNextQuestion" onchange="CreateQuestion()">
            <option value="-1">...</option>
            <option value="25" questiontype="2" questiontext="Cau scale 3" scalefromtext="" scaletotext=""
                scalefrom="0" scaleto="0">3</option>
            <option value="26" questiontype="3" questiontext="Lê Hữu Phú" scalefromtext="" scaletotext=""
                scalefrom="0" scaleto="0">4</option>
            <option value="30" questiontype="4" questiontext="Câu hỏi scale" scalefromtext="Phu"
                scaletotext="Tu" scalefrom="1" scaleto="10">5</option>
            <option value="31" questiontype="5" questiontext="Câu hỏi ma trận" scalefromtext=""
                scaletotext="" scalefrom="0" scaleto="0">6</option>
            <option value="34" questiontype="5" questiontext="caua whoi tsamh" scalefromtext=""
                scaletotext="" scalefrom="0" scaleto="0">7</option>
            <option value="40" questiontype="5" questiontext="Ma tran" scalefromtext="" scaletotext=""
                scalefrom="0" scaleto="0">8</option>
        </select>
    </div>
    <button onclick="test()">
        test
    </button>
    <div id="Result">
    </div>
</body>
</html>
